package com.sgb.kjwl.view.ui.fragment.material;

import android.os.Bundle;

import androidx.databinding.DataBindingUtil;
import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.sgb.kjwl.R;
import com.sgb.kjwl.databinding.FragmentNewDemandHallBinding;
import com.sgb.kjwl.view.ui.adapter.CommPagerAdapter2;
import com.swgk.core.view.entity.MenuEntity;
import com.sgb.kjwl.view.ui.activity.material.hall.NewPickBiddingListFragment;
import com.sgb.kjwl.view.ui.fragment.demandHall.CustomerInquiryFragment;
import com.sgb.jicai.view.fragment.JiCaiXuFangFaQiFragment;
import com.sgb.kjwl.view.ui.fragment.home.LazyFragment2;
import com.sgb.kjwl.view.ui.fragment.pick.PickHallBidingFragment;
import com.swgk.core.base.BaseFragment;
import com.swgk.core.base.di.AppComponent;

import java.util.ArrayList;
import java.util.List;

/**
 * A simple {@link Fragment} subclass.
 * Use the {@link NewDemandHallFragment#newInstance} factory method to
 * create an instance of this fragment.
 * by hq 2021.04.03
 * app首页商品模块的需求大厅
 *
 * @author Administrator
 */
public class NewDemandHallFragment extends LazyFragment2 {

    private FragmentNewDemandHallBinding binding;
    private static final String ARG_PARAM1 = "param1";
    private static final String ARG_PARAM2 = "param2";

    /**
     * Use this factory method to create a new instance of
     * this fragment using the provided parameters.
     *
     * @param param1 Parameter 1.
     * @param param2 Parameter 2.
     * @return A new instance of fragment NewDemandHallFragment.
     */
    public static NewDemandHallFragment newInstance(String param1, String param2) {
        NewDemandHallFragment fragment = new NewDemandHallFragment();
        Bundle args = new Bundle();
        args.putString(ARG_PARAM1, param1);
        args.putString(ARG_PARAM2, param2);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    protected void setupFragmentComponent(AppComponent appComponent) {

    }

    @Override
    protected void onMultiClick(View v) {

    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        binding = DataBindingUtil.inflate(inflater, R.layout.fragment_new_demand_hall, container, false);
        return binding.getRoot();
    }


    @Override
    protected void initView() {
        CommPagerAdapter2 goodsFragmentPagerAdapter;
        ArrayList<BaseFragment> fragmentList = new ArrayList<>();
        List<MenuEntity> table = new ArrayList<>();
        List<String> names = new ArrayList<>();
        names.add("客户询价");
        names.add("招标大厅");
        names.add("竞价采购");
        names.add("需方集采");
        names.add("企业专项");

        for (int i = 0; i < names.size(); i++) {
            MenuEntity entity = new MenuEntity(String.valueOf(i), names.get(i));
            table.add(entity);
//            fragmentList.add(XufangFaQiFragment.newInstance());
        }
        //每个Fragment传1显示搜索，传其他隐藏
        //客户询价
//        fragmentList.add(DemandHallFragment.newInstance(1));
        fragmentList.add(CustomerInquiryFragment.newInstance(0));
        //商品招标 PickSigningUplistActivity(已改造实现同步)
        //fragmentList.add(NewPickSigningUpListFragment.newInstance("0"));
        //招标大厅  PickHallBidingFragment(已改造实现同步)
        fragmentList.add(PickHallBidingFragment.newInstance("0"));
//        fragmentList.add(PickHallFragment.newInstance("1"));
        //招标预告 PickNoticeActivity(已改造实现同步)
//        fragmentList.add(PickNoticeFragment.newInstance("0"));
        //竞价集购  PickBiddingListActivity(已改造实现同步)
        fragmentList.add(NewPickBiddingListFragment.newInstance("0"));
        //需方集采 XuFangFaQiActivity(已改造实现同步)
//        fragmentList.add(XufangFaQiFragment.newInstance("1"));
        fragmentList.add(JiCaiXuFangFaQiFragment.newInstance(1, "1","1", "0",""));//新增type区分是否加载集采方式
        //企业专项 CentralizedTypeActivity(已改造实现同步)
//        fragmentList.add(NewCentralizedMiningFragment.newInstance("1"));
        fragmentList.add(JiCaiXuFangFaQiFragment.newInstance(1,"2","1","0",""));//新增type区分是否加载集采方式
//        fragmentList.add(CentralizedMiningFragment3.newInstance(0, 1, "", "3", 1, "", "0"));

        goodsFragmentPagerAdapter = new CommPagerAdapter2(getChildFragmentManager(), fragmentList, table);
        binding.viewPager.setAdapter(goodsFragmentPagerAdapter);
        binding.tabLayout.setupWithViewPager(binding.viewPager);
        binding.viewPager.setCurrentItem(0);
    }

}